package com.yc.booktable.controller;

import com.yc.booktable.entity.AdminUser;
import com.yc.booktable.entity.Bookinfo;
import com.yc.booktable.entity.Feedback;
import com.yc.booktable.mapper.BookinfoMapper;
import com.yc.booktable.mapper.FeedbackMapper;
import com.yc.booktable.vo.Result;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
public class PersonalController {
    @Resource
    private BookinfoMapper mapper;
    @Resource
    private FeedbackMapper feedbackMapper;

    @GetMapping("personinit")
    public Result personal(HttpSession session){
        AdminUser user = (AdminUser) session.getAttribute("loginedUser");
        return new Result(1,"获取成功",user);
    }

    @GetMapping("selectBook")
    public Result selectBook(HttpSession session){
        AdminUser user = (AdminUser) session.getAttribute("loginedUser");
        Long id = user.getId();
        List<Bookinfo> list = mapper.selectUserBook(id);
        return new Result(1,"获取成功",list);
    }
    @GetMapping("selectFeed")
    public Result selectFeed(HttpSession session){
        AdminUser user = (AdminUser) session.getAttribute("loginedUser");
        Long id = user.getId();
        List<Feedback> list = feedbackMapper.selectUserFeed(id);
        return new Result(1,"获取成功",list);
    }

}